package com.outsource.framework.util.partyc.ecaop.flow;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.outsource.framework.domain.Tuserflow;
import com.outsource.framework.util.common.DateUtils;

public class FlowClient {
	private static final Log log = LogFactory.getLog(FlowClient.class);

	public String requestFlow(String mobile){
		log.info("request get user flow:::::::::");
		return Flowget.getUserFolw(mobile);
	}
	
	public Tuserflow responseFlow(String mobile){
		String responseString = this.requestFlow(mobile);
		log.info("response px flow entry::::::::");
		FlowResponse fr = Flowget.FlowEntry(responseString);
		Tuserflow entity = null;
		if(fr!=null){
			entity = new Tuserflow();
			entity.setMobile(mobile);
			entity.setNettype(fr.getNettype());
			entity.setDetailenddate(fr.getDetailenddate());
			entity.setDetailstartdate(fr.getDetailstartdate());
			entity.setProductname(fr.getProductname());
			entity.setFlowpackagename(fr.getFlowpackagename());
			entity.setUsedflow(fr.getUsedflow());
			entity.setTotalflow(fr.getTotalflow());
			entity.setUpdatetime(new Date());
			entity.setMonth(DateUtils.getMonth()+"");
			entity.setDate(DateUtils.getDay()+"");
		}
		return entity;
	}
	
}
